<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:php="http://php.net/xsl" xmlns="http://www.w3.org/1999/xhtml">
	<xsl:template name="Translation">
		<xsl:call-template name="BoMenu" />
		<style>
			input[type="text"], table, textarea {
				width:100%;
			}
		</style>
		<h1>Project Translations</h1>

		<!-- Global Translations (site.tld.lang.php) -->
		<xsl:if test="count(//View/langs/site/properties/property) &gt; 0">
			<h3>Global Translations</h3>
			<form action="" method="post">
				<input type="hidden" name="reload_translate" value="true" />
				<input type="hidden" name="target_id" value="site" />
				<table class="bo_table_visible" style="margin-top:0" id="site">
					<tr class="summary">
						<th style="width:300px;">Label</th>
						<xsl:for-each select="//Statics/Sls/Configs/site/langs/name" >
							<th>Language '<xsl:value-of select="." />'</th>
						</xsl:for-each>
					</tr>
					<xsl:for-each select="//View/langs/site/properties/property">
						<tr>
							<td><xsl:value-of select="name" /></td>
							<xsl:variable name="position" select="position()" />
							<xsl:for-each select="//Statics/Sls/Configs/site/langs/name" >
								<xsl:variable name="lang" select="." />
								<td>
									<xsl:if test="//View/langs/site/properties/property[$position]/values/value[lang=$lang]/type = 'input'">
										<input type="text" name="{concat('LG_',$lang,'_',//View/langs/site/properties/property[$position]/name)}" value="{//View/langs/site/properties/property[$position]/values/value[lang=$lang]/name}" />
									</xsl:if>
									<xsl:if test="//View/langs/site/properties/property[$position]/values/value[lang=$lang]/type = 'textarea'">
										<textarea rows="5" name="{concat('LG_',$lang,'_',//View/langs/site/properties/property[$position]/name)}">
											<xsl:value-of select="//View/langs/site/properties/property[$position]/values/value[lang=$lang]/name" />
										</textarea>
									</xsl:if>
								</td>
							</xsl:for-each>
						</tr>
					</xsl:for-each>
				</table>
				<input type="submit" value="Update" />
			</form>
		</xsl:if>
		<!-- /Global Translations (site.tld.lang.php) -->

		<!-- Controllers Translations -->
		<h3>Controllers Translations</h3>
		<xsl:for-each select="//View/langs/controllers/controller">
			<xsl:variable name="positionC" select="position()" />
			<xsl:if test="count(properties/property) &gt; 0 or count(actions/action) &gt; 0">
				<h5>Controller '<xsl:value-of select="name" />'</h5>
				<xsl:if test="count(properties/property) = 0">
					This Controller haven't yet any language properties.
				</xsl:if>
				<xsl:if test="count(properties/property) &gt; 0">
					<form action="" method="post">
						<input type="hidden" name="reload_translate" value="true" />
						<input type="hidden" name="target_id" value="{id}" />
						<table class="bo_table_visible" style="margin-top:0" id="{id}">
							<tr class="summary">
								<th style="width:300px;">Label</th>
								<xsl:for-each select="//Statics/Sls/Configs/site/langs/name" >
									<th>Language '<xsl:value-of select="." />'</th>
								</xsl:for-each>
							</tr>
							<xsl:for-each select="properties/property">
								<tr>
									<td><xsl:value-of select="name" /></td>
									<xsl:variable name="position" select="position()" />
									<xsl:for-each select="//Statics/Sls/Configs/site/langs/name" >
										<xsl:variable name="lang" select="." />
										<td>
											<xsl:if test="//View/langs/controllers/controller[$positionC]/properties/property[$position]/values/value[lang=$lang]/type = 'input'">
												<input type="text" name="{concat('LG_',$lang,'_',//View/langs/controllers/controller[$positionC]/properties/property[$position]/name)}" value="{//View/langs/controllers/controller[$positionC]/properties/property[$position]/values/value[lang=$lang]/name}" />
											</xsl:if>
											<xsl:if test="//View/langs/controllers/controller[$positionC]/properties/property[$position]/values/value[lang=$lang]/type = 'textarea'">
												<textarea rows="5" name="{concat('LG_',$lang,'_',//View/langs/controllers/controller[$positionC]/properties/property[$position]/name)}">
													<xsl:value-of select="//View/langs/controllers/controller[$positionC]/properties/property[$position]/values/value[lang=$lang]/name" />
												</textarea>
											</xsl:if>
										</td>
									</xsl:for-each>
								</tr>
							</xsl:for-each>
						</table>
						<input type="submit" value="Update" />
					</form>
				</xsl:if>

				<!-- Actions Translations -->
				<xsl:if test="count(actions/action) = 0">
					This Controller haven't yet any actions.
				</xsl:if>
				<xsl:if test="count(actions/action) &gt; 0">
					<div style="margin-left:40px;">
						<h5>Actions</h5>
						<xsl:for-each select="actions/action">
							<xsl:variable name="positionA" select="position()" />
							<fieldset style="display:block;">
								<legend>Action '<xsl:value-of select="name" />'</legend>
								<xsl:if test="count(properties/property) = 0">
									This Action haven't yet any language properties.
								</xsl:if>
								<xsl:if test="count(properties/property) &gt; 0">
									<form action="" method="post">
										<input type="hidden" name="reload_translate" value="true" />
										<input type="hidden" name="target_id" value="{id}" />
										<table class="bo_table_visible" style="margin-top:0" id="{id}">
											<tr class="summary">
												<th style="width:300px;">Label</th>
												<xsl:for-each select="//Statics/Sls/Configs/site/langs/name" >
													<th>Language '<xsl:value-of select="." />'</th>
												</xsl:for-each>
											</tr>
											<xsl:for-each select="properties/property">
												<tr>
													<td><xsl:value-of select="name" /></td>
													<xsl:variable name="position" select="position()" />
													<xsl:for-each select="//Statics/Sls/Configs/site/langs/name" >
														<xsl:variable name="lang" select="." />
														<td>
															<xsl:if test="//View/langs/controllers/controller[$positionC]/actions/action[$positionA]/properties/property[$position]/values/value[lang=$lang]/type = 'input'">
																<input type="text" name="{concat('LG_',$lang,'_',//View/langs/controllers/controller[$positionC]/actions/action[$positionA]/properties/property[$position]/name)}" value="{//View/langs/controllers/controller[$positionC]/actions/action[$positionA]/properties/property[$position]/values/value[lang=$lang]/name}" />
															</xsl:if>
															<xsl:if test="//View/langs/controllers/controller[$positionC]/actions/action[$positionA]/properties/property[$position]/values/value[lang=$lang]/type = 'textarea'">
																<textarea rows="5" name="{concat('LG_',$lang,'_',//View/langs/controllers/controller[$positionC]/actions/action[$positionA]/properties/property[$position]/name)}">
																	<xsl:value-of select="//View/langs/controllers/controller[$positionC]/actions/action[$positionA]/properties/property[$position]/values/value[lang=$lang]/name" />
																</textarea>
															</xsl:if>
														</td>
													</xsl:for-each>
												</tr>
											</xsl:for-each>
										</table>
										<input type="submit" value="Update" />
									</form>
								</xsl:if>
							</fieldset>
						</xsl:for-each>
					</div>
				</xsl:if>
				<!-- /Actions Translations -->

			</xsl:if>
		</xsl:for-each>
		<!-- /Controllers Translations -->

		<!-- Focus -->
		<xsl:if test="count(//View/langs/target_id) &gt; 0">
			<script type="text/javascript">
				window.location = '#<xsl:value-of select="//View/langs/target_id" />';
			</script>
		</xsl:if>
		<!-- /Focus -->
	</xsl:template>
</xsl:stylesheet>